﻿@inherits EntitesGridModel<Entity.Key>

<EntitiesGrid Items="@Collection" TableClass="table mb-0">
    <TableHeader>
        <th></th>
        @if(ShowAlgorithm)
        {
            <th scope="col" class="w-25">
                <SortableHeader Property="Kind"
                                Text="@Localizer["algorithm"]"
                                GridState="GridState" />
            </th>
        }
        <th scope="col" class="w-25">
            <SortableHeader Property="CreationDate"
                            Text="@Localizer["creation"]"
                            GridState="GridState" />
        </th>
        <th scope="col" class="w-25">
            <SortableHeader Property="ActivationDate"
                            Text="@Localizer["activation"]"
                            GridState="GridState" />
        </th>
        <th scope="col" class="w-25">
            <SortableHeader Property="ExpirationDate"
                            Text="@Localizer["expiration"]"
                            GridState="GridState" />
        </th>
        <th></th>
    </TableHeader>
</EntitiesGrid>
@if (Collection == null)
{
    <Loading />
}
else
{
    <EntitiesGrid Items="@Collection" TableClass="table" Context="key">
        <RowTemplate>
            <td class="@GetRevokedClass(key)">
                @if (key.IsDefault)
                {
                    <h3 class="text-warning">*</h3>
                }
            </td>
            @if (ShowAlgorithm)
            {
                <td class="w-25 @GetRevokedClass(key)">
                    @key.Kind
                </td>
            }
            <td class="w-25 @GetRevokedClass(key)">
                @key.CreationDate.ToLocalTime()
            </td>
            <td class="w-25 @GetRevokedClass(key)">
                @key.ActivationDate.ToLocalTime()
            </td>
            <td class="w-25 @GetRevokedClass(key)">
                @key.ExpirationDate.ToLocalTime()
            </td>
            <td>
                @if (!key.IsRevoked)
                {
                    <RevokeButton Key="@key" RevokeConfirmed="RevokeConfirmed" />
                }
            </td>
        </RowTemplate>
    </EntitiesGrid>
}